package com.example.nio.util;

import cn.hutool.json.JSONUtil;
import com.example.nio.commons.Message;
import com.example.nio.commons.User;
import io.netty.channel.Channel;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

import java.util.List;

public class BridgeUtil {
    //服务器发送信息到客户端
    public static void toClient(Message message, Channel channel){
        channel.writeAndFlush(new TextWebSocketFrame(JSONUtil.toJsonStr(message)));
    }

    //服务器发送集合到客户端
    public static void toClientByList(List<User> userList,Channel channel){

        channel.writeAndFlush(new TextWebSocketFrame(userList.toString()));
    }

}
